package com.bing.bingPro.controller.fiveOrder;

import com.bing.bingPro.ExcelUtil;
import com.bing.bingPro.common.BaseResult;
import com.bing.bingPro.controller.dto.TFiveOrderTypeDto;
import com.bing.bingPro.controller.vo.TMoveOrderVo;
import com.bing.bingPro.service.TMoveOrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 工单详表-移机工单详表(t_move_order)
 */
@RestController
public class TMoveOrderController {

    @Resource
    private TMoveOrderService tMoveOrderService;

    /**
     * 移机工单详表-列表
     *
     * @param tOrderYearDto
     * @return
     */
    @PostMapping("/moveList")
    public BaseResult<List<TMoveOrderVo>> moveList(@RequestBody TFiveOrderTypeDto tOrderYearDto) {
        return new BaseResult<>(this.tMoveOrderService.moveList(tOrderYearDto));
    }


    /**
     * 移机工单详表-导出
     *
     * @param response
     * @param tOrderYearDto
     * @throws Exception
     */
    @PostMapping("/exportMove")
    public void exportMove(HttpServletResponse response, @RequestBody TFiveOrderTypeDto tOrderYearDto) throws Exception {
        long x = System.currentTimeMillis();
        System.out.println(x);
        List<TMoveOrderVo> tMoveOrderVos = tMoveOrderService.exportMove(tOrderYearDto);
        Long l = System.currentTimeMillis();
        Long x1 = l-x;
        System.out.println("查询耗时"+x1);
        String monthOrDayTime = "移机工单详表" + tOrderYearDto.getTime();
        ExcelUtil.writeExcel(response, tMoveOrderVos, monthOrDayTime,
                "移机工单详表" + tOrderYearDto.getTime(), TMoveOrderVo.class);
        long l1 = System.currentTimeMillis();
        Long y = l1 - l;
        System.out.println("导出耗时>>>>>>>>>"+y);
    }
}
